<?php

namespace App\HttpController\Api\Admin\Access;

use App\HttpController\Api\Admin\AdminBase;
use App\Lib\Utils;
use App\Model\Face\FaceModel;
use EasySwoole\Http\Message\Status;

class Visitor extends AdminBase
{

    public function index()
    {
        $model = new FaceModel();
        $str = $this->raw;
        $model->params = json_decode(Utils::characet($str),true);
        $data = $model->getList();
        if (!$data) {
            return $this->writeJson(Status::CODE_BAD_REQUEST, "Server Error".$model->message);
        }

        $this->response()->withHeader('Content-Type', 'application/json;charset=utf-8');
        $this->response()->write(json_encode([
            'code' => 0,
            'data' => $data['lists'],
            'count' => $data['count'],
        ]));
    }

}